var util = require('../../utils/util.js');
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    hasUserInfo: false,
    goodId:'',
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    menuitems: [
      { text: '商品名', url: '', icon: '../image/订单.png', tips: '',context:""},
      { text: '游戏名', url: '', icon: '../image/订单.png', tips: '',context:""},
      { text: '价格', url: '', icon: '../image/价格.png', tips: '',context:""},
      { text: '支付方式', url: '', icon: '../image/价格.png', tips: '',context:"微信"},
    ],
  },
  
onLoad:function(options){
  
var that = this
 let c0 = 'menuitems['+0+'].context'
 let c1 = 'menuitems['+1+'].context'
 let c2 = 'menuitems['+2+'].context'
  that.setData({
    [c0]:options.goodName,
    [c1]:app.globalData.gameImage[options.gameId].name ,
    [c2]:options.goodPrice,
    goodId:options.goodId
  })

},
  buy:function(){
    var that=this
    wx.request({
    url:app.globalData.url+'goodSellAction',
    data:{
      goodId:that.data.goodId
    },
})
wx.request({
  url:app.globalData.url+'dealAddAction',
  data:{
    userId:app.globalData.userInfoList.userId,
    goodId:that.data.goodId,
    dealTime:util.formatTime(new Date()),
  },
})
  }
})